Fixes Foundry Hosted Agents HTTP endpoints#16130
Fixes Foundry Hosted Agents HTTP endpoints#16130tommasodotNET wants to merge 23 commits intomicrosoft:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16130Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16130" |
There was a problem hiding this comment.
Pull request overview
Updates the Foundry hosted-agent run-mode behavior to avoid endpoint conflicts when PublishAsHostedAgent is applied to resources that already define HTTP endpoints, and adds a new playground sample for hosted agents.
Changes:
- In run mode, removes existing HTTP/HTTPS endpoint annotations before adding the hosted-agent HTTP endpoint.
- Refactors publish-mode containerization to explicitly handle
ProjectResourcevsExecutableResource. - Adds a
playground/FoundryHostedAgentssample (AppHost + Python agent app scaffolding).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs | Adds tests asserting hosted-agent run-mode endpoint overwrite behavior and non-hardcoded port behavior. |
| src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs | Implements endpoint removal in run mode and adjusts publish-mode containerization logic. |
| playground/FoundryHostedAgents/aspire.config.json | Adds Aspire config pointing to the new playground AppHost. |
| playground/FoundryHostedAgents/app/pyproject.toml | Adds Python agent sample dependencies/config. |
| playground/FoundryHostedAgents/app/main.py | Adds Python agent sample implementation. |
| playground/FoundryHostedAgents/app/.dockerignore | Adds Docker ignore rules for the Python sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/appsettings.json | Adds logging configuration for the new AppHost sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/appsettings.Development.json | Adds development Azure settings for the sample (currently includes specific identifiers). |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/Properties/launchSettings.json | Adds launch profiles for the new AppHost sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/FoundryHostedAgents.AppHost.csproj | Adds a new AppHost project file for the playground sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/AppHost.cs | Adds the new playground AppHost wiring for Foundry + Python hosted agent. |
…settings.Development.json Co-authored-by: Copilot <[email protected]>
…m:tommasodotNET/aspire into fix/hosted-agent-overwrite-http-endpoints
…sion.cs Co-authored-by: Copilot <[email protected]>
…m:tommasodotNET/aspire into fix/hosted-agent-overwrite-http-endpoints
|
UPDATE: instead of removing the existing endpoints, we can overwrite them. looks like a better solution. The fix still enables use with dotnet hosted agents (sample added). |
|
|
||
| var tenantId = builder.AddParameterFromConfiguration("tenant", "Azure:TenantId"); | ||
|
|
||
| var foundry = builder.AddFoundry("aif-myfoundry"); |
There was a problem hiding this comment.
We should consider making a deployment end-to-end test out of this.
See https://github.com/microsoft/aspire/tree/main/.github/skills/deployment-e2e-testing and https://github.com/microsoft/aspire/tree/main/tests/Aspire.Deployment.EndToEnd.Tests
There was a problem hiding this comment.
i've tried adding one. not sure if it's correct, though
…ntBuilderExtension
…package versions to 1.1.0 and 10.4.0 respectively
| Assert.True(app.Resource.TryGetEndpoints(out var endpoints)); | ||
| var httpEndpoints = endpoints.Where(e => e.Name == "http").ToList(); | ||
| Assert.Single(httpEndpoints); | ||
| Assert.Equal(8088, httpEndpoints[0].TargetPort); |
There was a problem hiding this comment.
? shouldn't this be 5000
There was a problem hiding this comment.
PublishAsHostedAgent overwrites the http endpoints on the resource. this is needed because you could have a generic PythonApp hosting an agent with microsoft agent framework.
but the the user can explicitly set his own target port, adding .WithHttpEndpoint() after invoking PublishAsHostedAgent().
so this test is verifying that whichever previously defined http endpoint gets overwritten to standard foundry hosted agent default value 8088.
it's not ideal, tbh. the thing is hosting the agent for foundry via microsoft agent framework usually expose the agent at 8088 as default, unless otherwise specified in the DEFAULT_AD_PORT internal env var. so to map different targetPorts you can do what i did in the playground in this pr (look at the dotnet app).
There was a problem hiding this comment.
i'm working on a fix for this scenario btw. commit incoming. if an "http" endpoint already exists, we use the target port defined in that one, otherwise we default to 8088
Description
Closes #16115. Overwrites existing http/https endpoints on resource to allow the creation of dedicated hosted agent endpoint. Does not hard code http port (letting aspire handle port assignment).
PublishAsHostedAgentaccepts generic resource with endpoint (e.g. ProjectResource) allowing hosted agents in dotnet (see also #15968).Allows for custom targetPorts to allow locally run multiple hosted agents
Adds a playground sample for hosted agents in python
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: